#ifndef YXJWT_H
#define YXJWT_H
#include "Jwt.h"

#define YX_JWT_DEAULT_SECRET "yxyyxhyh"
#define YX_JWT_DEAULT_EXPIRE 36000

#define YX_JWT_CLAIMS_DEFAULT_CAPACITY 5

typedef struct JwtBuilder {
    struct l8w8jwt_encoding_params *params;
    int                             claims_capacity;
} JwtBuilder;

typedef struct Claims {
    struct l8w8jwt_claim *claims;
    size_t                size;
} Claims;

JwtBuilder *yx_jwt_create();
void        yx_jwt_add_claims_int(JwtBuilder *jwt_builder, char *key, int key_len, long value);
void        yx_jwt_add_claims_str(JwtBuilder *jwt_builder, char *key, int key_len, char *value);
char       *yx_jwt_generate(JwtBuilder *jwt_builder);
Claims     *yx_jwt_parse(const char *token);
void        yx_jwt_free(char *token);
long        yx_jwt_claims_get_int(Claims *claims, char *key, size_t key_len);
char       *yx_jwt_claims_get_str(Claims *claims, char *key, size_t key_len);
void        yx_jwt_claims_free(Claims *claims);
void        yx_jwt_set_secret(char *secret, int len);
int         yx_jwt_set_expire(int expire);
char       *yx_jwt_get_secret();
int         yx_jwt_get_expire();

#endif // YXJWT_H
